#ifndef PFNODE_H
#define PFNODE_H

#include <QObject>
#include <QList>
#include "graphicsiplimgobject.h"
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>

const std::string INITPORT("10086");
const std::string CMDPORT("10000");
const std::string LIVEPORT("9696");
class PFNode : public QObject
{
    Q_OBJECT
public:
    explicit PFNode(std::string name, int totalThumbImg = PFCMU::TOTALCAMS, QObject *parent = 0);

    double getShutter() const;
    double getGain() const;
    void setNodeName(std::string name);
    std::string getNodeName() const;
    bool isLiving() const;
    int watchingCamIdx() const;
    bool isCapturing() const;
    bool checkReady() const;

    QList<GraphicsIplImgObject *> getThumbImages() const;
    GraphicsIplImgObject* getLiveImage() const;

signals:
    void clientEvent(QString str);
    void allImageDataReceived();

public slots:
    void setShutter(double shutter);
    void setGain(double gain);
    void setToWatching(int cam);
    void setNotWatching();
    void startConnection();
    void startCapture(QStringList paraCapture);

private:
    double m_Shutter;
    double m_Gain;
    const unsigned int m_Fps;
    const unsigned int m_Width, m_Height;
    std::string m_NodeName;
    const unsigned int TOTALCAMS;

    bool m_IsLiving;
    bool m_IsWatching;
    bool m_IsCapturing;
    bool m_IsInit;
    bool m_IsRunning;
    int m_WatchingCam;

    bool m_SetShutter;
    bool m_SetGain;

    QList<GraphicsIplImgObject *> m_ThumbImg;
    GraphicsIplImgObject *m_LiveImg;

    std::string m_CaptureFName;
    unsigned int m_CaptureFrames;

    void localClient(std::string nodeName, std::string nodePort);
    boost::mutex mu;
    boost::condition_variable_any cond;

    /*event*/
    void event_ConnectionEst(int fps);
    void event_CommandNotSend(std::string cmd);


};

#endif // PFNODE_H
